package com.blank.web.servlet;

import com.blank.web.bean.ClassBean;
import com.blank.web.dao.ClassDao;
import com.blank.web.service.ClassService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "afterUpdateClassServlet",urlPatterns = "/afterUpdateClass")
public class afterUpdateClassServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        ClassBean classBean = new ClassBean();
        classBean.setCid(Integer.parseInt(request.getParameter("cid")));
        classBean.setGrade(Integer.parseInt(request.getParameter("grade")));
        classBean.setTeacherName(request.getParameter("teacherName"));
        classBean.setSlogan(request.getParameter("slogan"));
        classBean.setClassNum(Integer.parseInt(request.getParameter("classNum")));

        ClassService classService = new ClassService();
        classService.updateClass(classBean);

        request.getRequestDispatcher("showClassInfo").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
